Inheritance is the mechanism which
allows a class A to inherit
properties of a class B. We say “A inherits from B''. Objects of class A thus have
access to attributes and methods of class B without the need to redefine them.
If class A inherits from class B, then B is called superclass (or parent
class) of A. A
is called subclass (or derived class) of B. Objects of a subclass can be used where objects
of the
corresponding superclass are expected. This is due to the fact that objects of the
subclass share the same behaviour as objects of the
superclass.